package com.wolfking.jeesite.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wolfking.jeesite.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户的mapper映射
 * 
 * @author wolfking@赵伟伟
 * @mail zww199009@163.com
 * @创作日期 2017年4月23日 上午10:56:28
 * @copyright wolfking
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {



	@Select("select DISTINCT u.* from sys_user u inner join sys_user_role ur on u.id = ur.user_id "
			+ "where ur.role_id = #{roleId}")
	List<User> getUserByRoleId(@Param("roleId") Integer roleId);

	@Select("select DISTINCT (m.permission) from sys_user_role ur "
			+ " inner join sys_role_menu rm  on ur.role_id = rm.role_id "
			+ " inner join sys_menu m on rm.menu_id = m.id  "
			+ " where ur.user_id = #{userId} and length(m.permission) >0 ")
	List<String> getUserAllAuthCodes(@Param("userId") Integer userId);


}
